accurrent2 2.2.1
Loading...
Searching...
No Matches
accurrent2


AC Current 2 Click

AC Current 2 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.


Click Library

  • Author : Stefan Filipovic
  • Date : Feb 2025.
  • Type : ADC/I2C type

Software Support

Example Description

This example demonstrates how to use the AC Current 2 Click board for reading the measurements from the AC Current sensor attached to the Click board input.

Example Libraries

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.ACCurrent2

Example Key Functions

  • accurrent2_cfg_setup This function initializes Click configuration structure to initial values.
    void accurrent2_cfg_setup(accurrent2_cfg_t *cfg)
    AC Current 2 configuration object setup function.
    AC Current 2 Click configuration object.
    Definition accurrent2.h:159
  • accurrent2_init This function initializes all necessary pins and peripherals used for this Click board.
    err_t accurrent2_init(accurrent2_t *ctx, accurrent2_cfg_t *cfg)
    AC Current 2 initialization function.
    AC Current 2 Click context object.
    Definition accurrent2.h:144
  • accurrent2_read_current This function reads the current measurement from the AC Current sensor (30A/1V).
    err_t accurrent2_read_current ( accurrent2_t *ctx, float *current );
    err_t accurrent2_read_current(accurrent2_t *ctx, float *current)
    AC Current 2 read current function.

Application Init

Initializes the driver and logger.

void application_init ( void )
{
log_cfg_t log_cfg;
accurrent2_cfg_t accurrent2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accurrent2_cfg_setup( &accurrent2_cfg );
err_t init_flag = accurrent2_init( &accurrent2, &accurrent2_cfg );
if ( ( ADC_ERROR == init_flag ) || ( I2C_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define ACCURRENT2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition accurrent2.h:120
void application_init(void)
Definition main.c:36
#define MIKROBUS_POSITION_ACCURRENT2
Definition main.c:30

Application Task

Continuously reads the AC current value and logs the measured data in amperes (A).

void application_task ( void )
{
float current = 0;
if ( ACCURRENT2_OK == accurrent2_read_current ( &accurrent2, &current ) )
{
log_printf( &logger, " AC Current : %.3f A\r\n\n", current );
Delay_ms ( 1000 );
}
}
@ ACCURRENT2_OK
Definition accurrent2.h:180
void application_task(void)
Definition main.c:67

Note

The AC Current sensor [MIKROE-2524] required for this Click board should have a specification of 30A/1A.

Application Output

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
  • UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.

Additional Notes and Information

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.